package com.muzi.weshop.view.adapter;

import android.view.View;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.muzi.weshop.R;
import com.muzi.weshop.model.PersonnelModel;

import java.util.List;

/**
 * @author logcat
 */
public class ContactAdapter extends BaseQuickAdapter<PersonnelModel, BaseViewHolder> {

    private OnItemClickListener onItemClickListener;

    public void setOnItemClickListener(OnItemClickListener onItemClickListener) {
        this.onItemClickListener = onItemClickListener;
    }

    public ContactAdapter(int layoutResId, @Nullable List<PersonnelModel> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, PersonnelModel item) {
        helper.setText(R.id.tvAccount , item.getAccount());
        helper.itemView.findViewById(R.id.tvAccount).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(onItemClickListener != null){
                    onItemClickListener.onItemClick(item);
                }
            }
        });
    }


    public interface OnItemClickListener{
        void onItemClick(PersonnelModel data);
    }
}
